﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UtilZ.Dotnet.Ex.Communication.Net.Web
{
    /// <summary>
    /// web服务器常量定义类
    /// </summary>
    public class WebConstnats
    {
        /// <summary>
        /// 一个回车换行(\r\n)对应的二进制
        /// </summary>
        public readonly static ReadOnlyCollection<byte> ENTER_NEWLINE_BINARY = null;

        /// <summary>
        /// 两个回车换行(\r\n\r\n)对应的二进制
        /// </summary>
        public readonly static ReadOnlyCollection<byte> DOUBLE_ENTER_NEWLINE_BINARY = null;

        /// <summary>
        /// 与号数组
        /// </summary>
        public readonly static char[] AND_MARK_ARR = null;

        /// <summary>
        /// 逗号数组
        /// </summary>
        public readonly static char[] COMMA_MARK_ARR = null;

        /// <summary>
        /// 一个回车换行
        /// </summary>
        public readonly static string[] ENTER_NEWLINE_ARR = null;





        /// <summary>
        /// 一个空格
        /// </summary>
        public readonly static char[] ONE_SPACE_ARR = null;

        /// <summary>
        /// 冒号
        /// </summary>
        public readonly static char[] COLON_MARK_ARR = null;

        /// <summary>
        /// 分号
        /// </summary>
        public readonly static char[] SEMICOLON_MARK_ARR = null;

        /// <summary>
        /// 等号
        /// </summary>
        public readonly static char[] EQUAL_MARK_ARR = null;

        /// <summary>
        /// 路径分隔符
        /// </summary>
        public readonly static char[] PATH_SEPARATOR_ARR = null;



        static WebConstnats()
        {
            ENTER_NEWLINE_BINARY = new ReadOnlyCollection<byte>(new byte[] { 13, 10 });
            DOUBLE_ENTER_NEWLINE_BINARY = new ReadOnlyCollection<byte>(new byte[] { 13, 10, 13, 10 });
            AND_MARK_ARR = new char[] { AND_MARK };
            COMMA_MARK_ARR = new char[] { ',' };
            ENTER_NEWLINE_ARR = new string[] { "\r\n" };

            ONE_SPACE_ARR = new char[] { ' ' };
            COLON_MARK_ARR = new char[] { ':' };
            SEMICOLON_MARK_ARR = new char[] { ';' };
            EQUAL_MARK_ARR = new char[] { '=' };
            PATH_SEPARATOR_ARR = new char[] { Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar, Path.PathSeparator };
        }









        /// <summary>
        /// http协议版本
        /// </summary>
        public const string HTTP_PROTOCOL_VER = "HTTP/1.1";

        /// <summary>
        /// 一个回车换行
        /// </summary>
        public const string ENTER_NEWLINE = "\r\n";

        /// <summary>
        /// 两个回车换行
        /// </summary>
        public const string DOUBLE_ENTER_NEWLINE = "\r\n\r\n";

        /// <summary>
        /// 问号
        /// </summary>
        public const char QUESTION_MARK = '?';

        /// <summary>
        /// 与号数组
        /// </summary>
        public const char AND_MARK = '&';

        /// <summary>
        /// 等号
        /// </summary>
        public const char EQUAL_MARK = '=';

        /// <summary>
        /// 分块发送标识
        /// </summary>
        public const string CHUNKED = "chunked";

        /// <summary>
        /// utf-8
        /// </summary>
        public const string UTF_8 = "utf-8";

        /// <summary>
        /// 横线
        /// </summary>
        public const string LINEAE_TRANSVERAE = "-";



        /// <summary>
        /// 星号
        /// </summary>
        public const char ASTERISK_MARK = '*';



        /// <summary>
        /// 字符集编码
        /// </summary>
        public const string CHARSET = "charset";

        /// <summary>
        /// 范围请求单位
        /// </summary>
        public const string REQUEST_RANGE_UNIT = "bytes";

        /// <summary>
        /// 当响应数据超过100MB时，则响应数据分片发送
        /// </summary>
        public const int RES_PART_CONTENT_MAX_SIZE = 1024 * 1024 * 100;

        /// <summary>
        /// 当接收到的数据超过100MB时，则写文件 
        /// </summary>
        public const int REQ_CONTENT_MAX_SIZE = 1024 * 1024 * 100;

        /// <summary>
        /// 连续从网络流中读取数据长度为0的数据最大次数，超过此值，认为连接已断开
        /// </summary>
        public const int CONTINUITY_READ_DATA_LEN_ZERO_COUNT = 5;
    }
}
